<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Reservation</title>
<link rel="stylesheet" type='text/css' href='css/style.css' />
<script type="text/javascript" src="js/rightclick.js"></script>
</head>
<body>

<div class="container" >

	<div class="navbar">
	<p>
	<a href="HostServlet" class="navbutton">Home</a> | <a href="AddCustomer" class="navbutton">Customers</a> | <a href="ViewTables" class="navbutton">Tables</a>
	</p>
	</div>

<h2>Create Reservation:</h2>

<p />
			<div class='findcustreservation'>

			<FORM METHOD=POST ACTION="Reservation">
				<b>Find Customer: </b><INPUT TYPE=TEXT NAME="keyword" SIZE=20>
				<INPUT class='loginbutton' TYPE=SUBMIT VALUE="Find" name="findcustomer">
			</FORM>
			
			</div>

<p />

			<c:if test="${ reservationsuccessful != null }">
			<div class='successfullmsg'>
				<h4>Reservation Added Successfully for ${ ondatetime }</h4>
			</div>
			</c:if>



			<c:if test="${ searched != null }">
					
			<c:choose>
		
				<c:when test = "${ empty customerresult[0] }">
				
				Customer not found. <a href='AddCustomer'>Click here</a> to create a record!
				
				</c:when>
			
			<c:otherwise>
					
					<h3>Results:</h3>
					
						<table  class="customertable">
						<thead>
							<tr>
								<th>First</th><th>Last</th><th>Address</th><th>Phone</th><th></th>
							</tr>
						</thead>
						<tbody>	
							<c:forEach items="${ customerresult }" var="customer">
								<tr><td>${customer.firstName}</td><td>${customer.lastName}</td><td>${customer.address}</td><td>${customer.phoneNumber}</td><td id='opaq'><a class='tablebutton' href="Reservation?createreservation=${customer.id}">Create Reservation</a></td></tr>
							</c:forEach>
						</tbody>
						</table>
						
						</c:otherwise>
						
						</c:choose>
			
			</c:if>
			
			<c:if test="${ reservenew != null }">
			
			<div class='createreservationdiv'>
			
				Create New Reservation for ${ newcustomer.firstName } ${newcustomer.lastName}, <br />
				
				<form id="form1" name="form1" method="post" action="Reservation">
				<p>
				<label>Date
				<input name="Date" type="text" id="Date" /><small><i>(ex. 10/23/2010)</i></small>
				</label>
				</p>
				<p>
				<label>Time
				<input name="Time" type="text" id="Time" /><small><i>(ex. 13:00 for 1pm)</i></small>
				</label>
				<p />

				<p>
				<label>
				<input type="hidden" VALUE="${ newcustomer.id }" name="customerId" />
				<input class='swapbutton' type="submit" name="newreservation" id="Submit" value="Submit" />
				</label>
				</p>
				</form>
				
				
			</div>
			
			</c:if>
			
<p><b> - OR - </b></p>

<p />
<h2>Find Reservation:</h2>
<p />

<div class='findcustreservation'>

			<FORM METHOD=POST ACTION="Reservation">
				<b>Date of Reservation:</b> <INPUT TYPE=TEXT NAME="date" SIZE=20>
				<INPUT class='loginbutton' TYPE=SUBMIT VALUE="Find" name="finddate">
				<br /><small><i>(ex. 02/17/1990)</i></small>
			</FORM>
			
			</div>

<p />

	<c:if test="${ triedtofind != null }">

	<p>

		<c:choose>
		
			<c:when test = "${ empty reservations[0] }">
			
			No reservations found on ${ finddate }.
			
			</c:when>
			
			<c:otherwise>
			
				<table  class="customertable">
				
				<thead>
					<tr>
						<th>Customer Name:</th><th>Reservation Time:</th><th></th>
					</tr>
				</thead>
				
				<tbody>
				
				<c:forEach items = "${ reservations }" var = "reservation">
			
					<tr>
						<td>${ reservation.customerName }</td>
						<td>${ reservation.reservationTime }</td>
						<td id='opaq'><a class='tablebutton' href="Reservation?removeres=${ reservation.reservationId }">Remove</a></td>
					</tr>
			
				</c:forEach>
				
				</tbody>
				
				</table>
				
			</c:otherwise>
		
		</c:choose>
		
	</p>

</c:if>

</div>

</body>
</html>